<template>
	<view :class="[primarySize()]">
		<view class="container">
			<view class="p30">
				<view class="search_box flex-box">
					<input type="text" confirm-type="search" v-model="q" @confirm="bindSearch" placeholder="请输入机构名称" class="flex-grow-1 inp fs28 pr30" placeholder-class="colb" />
					<image src="https://admin.mosizp.cn/static/public/icon_search.png" mode="aspectFill" class="ico28" @click="bindSearch"></image>
				</view>
				
				<institution-list :institutions="institutionList"></institution-list>
				
				<view class="nothing" v-if="institutionMore.nothing">
					<image src="https://admin.mosizp.cn/static/public/icon_nothing.png" mode="aspectFit"></image>
					<text>暂无培训机构</text>
				</view>
				<view class="g-btn3-wrap" v-else>
					<view class="g-btn3" @click="fetch()">{{institutionMore.text}}</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	import institutionList from '../../components/institution-list/institution-list.vue';
	export default {
		components: {
			institutionList
		},
		data() {
			return {
				
				q: '',
				institutionList: [],
				institutionMore: {page: 1}
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onLoad() {
			
			this.fetch()
		},
		onReachBottom() {
			this.fetch()
		},
		methods: {
			bindSearch(){
				this.refresh()
			},
			refresh(){
				this.institutionList = [];
				this.institutionMore = {page: 1};
				this.fetch();
			},
			fetch() {
			    this.$util.fetch(this, 'xilujob.train/index', {q:this.q.trim(),pagesize: 10}, 'institutionMore', 'institutionList', 'data', 'unique');
			}
			
		}
	}
</script>

<style lang="scss" scoped>
.search{
	&_box{
		width: 690rpx;
		height: 86rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(183,189,202,0.3);
		border-radius: 43rpx;
		padding-left: 40rpx;
		padding-right: 30rpx;
		.inp{
			color: var(--normalBlack);
		}
	}
}

</style>
